/*
 * A prime number (or a prime) is a natural number greater than 1
 * that has no positive divisors other than 1 and itself. A natural 
 * number greater than 1 that is not a prime number is called a *
 * composite number.
 * 0 and 1 are neither prime nor composite. 
*/

#include <stdio.h>
#include <math.h>

int is_prime(unsigned int data)
{
	unsigned int start;
    unsigned int end;

	end = (unsigned int)sqrt((double)(data));
	start = 2;
	while(start <= end) {
		if ((data % start) == 0)
			return 0;
		start++;
	}
	return 1;

}
int main(int argc, char *argv[])
{
	unsigned int range;
	unsigned int start;
	unsigned int retval;

	printf("please input max range\n");
	scanf("%d",&range);
	printf("the following numbers are prime, less than %d\n",range);

	for(start=2; start < (range + 1); start++) {
		if (retval = is_prime(start) )	
			printf("%d\n", start);
	}

	return 0;
}
